package com.liu.udp;

import java.io.IOException;
import java.net.*;

@SuppressWarnings({"all"})
public class UDPSendB {
    public static void main(String[] args) throws IOException {

        //创建DatagramSocket对象，准备发送和接收数据
        DatagramSocket datagramSocket = new DatagramSocket(8888);
        //将需要发送的数据封装到DatagramPacket对象中
        byte[] bytes = "hello,明天吃火锅".getBytes();
        DatagramPacket datagramPacket = new DatagramPacket(bytes, bytes.length, InetAddress.getLocalHost(), 9999);
        datagramSocket.send(datagramPacket);
        datagramSocket.close();
    }
}
